import { Injectable } from '@angular/core';
import { log } from 'console';
import { LocalForageService } from './local-forage.service';

@Injectable({
  providedIn: 'root',
})
export class AppServerService {
  //AppServerService刷新页面都会销毁重建
  constructor(private localForageService: LocalForageService) {
    console.log('AppServerService --- constructor');
  }
  //定时检测登录状态任务

  //检测登录状态任务
  loginStatusDetectionTask(): void {
    console.log('AppServerService --- loginStatusDetectionTask');
    //1读取storage的数据

    //2判断
    //2.1失效   清空用户信息 权限信息 token信息   返回登录页

    //2.2有效
  }

  ScheduledLoginStatusDetectionTask(): void {
    console.log('AppServerService --- ScheduledLoginStatusDetectionTask');
    //定时
    let intervalId = ''; //= setInterval(() => console.log(123), 1000 * 10);

    //this.localForageService.setItem('ScheduledLoginStatusDetectionTaskintervalId', intervalId + '');
    console.log(145646123);
  }

  StopScheduledLoginStatusDetectionTask(): void {
    console.log('AppServerService --- ScheduledLoginStatusDetectionTask');
    //this.localForageService.getItem('ScheduledLoginStatusDetectionTaskintervalId');
    //取消定时
    // if (null != intervalId) {
    //   clearInterval(intervalId);
    // }
  }

  //定时更新token任务

  //更新token任务
  refreshTokenTask(): void {
    console.log('AppServerService --- refreshTokenTask');
    //1读取storage的数据

    //判断 有效时间 过了没有   过了调刷新接口 回写storage数据
  }
}
